package com.heisenhub.uua.hander;

import com.heisenhub.uua.exception.ValidateCodeException;
import com.heisnenhub.common.module.handler.BaseExceptionHandler;
import com.heisnenhub.common.module.utils.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author sen
 * @description  全局异常处理器
 * @date 2023/12/18 11:06
 */
@Slf4j
@RestControllerAdvice
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class GlobalExceptionHandler extends BaseExceptionHandler {

    @ExceptionHandler(value = ValidateCodeException.class)
    public Api handleException(ValidateCodeException e) {
        log.error("认证码异常，异常信息", e);
        return Api.fail(e.getMessage());
    }
}